Kwik.Page.include("Kwik.Ui.Animations.Base.js");
Kwik.Page.include("Kwik.Ui.Css.js");

/** 
* Fade an element animated.
* @constructor 
* @extends Kwik.Ui.Animations.Base
* @requires Kwik.Ui.Animations.Base
* @requires Kwik.Ui.Css
* @created 9:18 PM 1/27/2009
* @modified 11:11 PM 6/27/2009
*/
Kwik.Ui.Animations.Fade = function(config)
{
	/** @ignore */
	Kwik.Utility.extend(this, "Kwik.Ui.Animations.Base");
	this.__class.push("Kwik.Ui.Animations.Fade");
	
	/** Begin opacity @type Number */
	this.begin = 0;
	/** End opacity @type Number */
	this.end = 100;
	/** Active opacity @type Number */
	this.active = 0;

	/** Set current step and change the opacity of the element according to the new status */
	this.setCurrent = function Fade_setCurrent(step)
	{
		this.Kwik$Ui$Animations$Base.setCurrent(step);
		this.active = this.begin - parseInt(((this.begin - this.end) / 100) * this.status);
		Kwik.Ui.Css.setOpacity(this.element, this.active);
	};
	
	/** Configure this fade animation @type Object */
	this.configure = function Fade_configure(config)
	{
		if(config && Kwik.Type.isNumber(config.begin)){this.begin = parseInt(config.begin);}
		if(config && Kwik.Type.isNumber(config.end)){this.end = parseInt(config.end);}
		config = this.Kwik$Ui$Animations$Base.configure(config);
		return config;
	};

	/** Get this fade animation as string @type String */
	this.toString = function Fade_toString()
	{
		return [
			this.Kwik$Ui$Animations$Base.toString(),
			"begin=" + this.begin.toString(),
			"end=" + this.end.toString(),
			"active=" + this.active
			].join(", ");
	};
	
	/** @ignore */
	this.main = function Fade_main(config)
	{
		if(config){this.configure(config);}
	}; this.main(config);
};
